#SDKPATH := ~/NVIDIA_GPU_Computing_SDK
SDKPATH := /opt/cuda/sdk
CUDAPATH := /opt/cuda
RTAUDIOPATH := /Users/kunu/shared/devel_libs/rtaudio-4.0.9

LDFLAGS := -L$(CUDAPATH)/lib64 -L$(SDKPATH)/shared/lib/darwin -L$(SDKPATH)/C/lib -Lexternal_libs\
	-lcuda \
	-lcudart \
	-lcutil_x86_64 \
	-lcurses

CXFLAGS := -I$(CUDAPATH)/include -I$(SDKPATH)/shared/inc -I$(SDKPATH)/C/common/inc -Iinclude -lpthread

RT_AUDIO_LIB := external_libs/RtAudio.o \
				-lasound

CUDA_CXFLAGS := -use_fast_math

CXX := g++
NVCC := $(CUDAPATH)/bin/nvcc

BIN := bin
SRCDIR := src
OBJDIR := obj
TARGET := run



all : $(BIN)/$(TARGET)

#MODULES = main rt_playback oscillators

CXX_SOURCES := main.cpp rt_playback.cpp
CXX_OBJS := $(CXX_SOURCES:%.cpp=%.o)

NVXX_SOURCES := oscillators.cu synthesiser.cu
NVXX_OBJS := $(NVXX_SOURCES:%.cu=%.o)

GLOBAL_SOURCES := globals.h

_OBJS := $(NVXX_OBJS) $(CXX_OBJS) 
OBJS := $(patsubst %,$(BIN)/%,$(_OBJS))

echo "building OBJS: "

#TARGET COMPILATION
$(BIN)/$(TARGET): $(OBJS)
	$(CXX) -o $@ $^ $(LDFLAGS) $(RT_AUDIO_LIB)

# CUDA COMPILATION
$(BIN)/%.o: $(SRCDIR)/%.cu
	$(NVCC) -c -o $@ $< $(CUDA_CXFLAGS) $(CXFLAGS)

# CPP COMPILATION
$(BIN)/%.o: $(SRCDIR)/%.cpp
	$(CXX) -c -o $@ $< $(CXFLAGS)

clean :
	rm $(OBJS)
